<section class="content-header">
    <h1>
        页面管理
        <small></small>
    </h1>
</section>

<!-- Main content -->
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <!-- general form elements -->
            <div class="box">
                <div class="box-header with-border">
                    <h3 class="box-title">新增页面</h3>
                </div>
                <!-- form start -->
                <form class="form-horizontal" action="/admin/page/add" method="post">
                    <div class="box-body">
                        <input class="form-control" name="id" placeholder="" value="{{page.id}}"
                               type="hidden">

                        <div class="form-group">
                            <label class="col-sm-2 control-label">名称</label>

                            <div class="col-sm-10">
                                <input class="form-control" name="name" placeholder="" value="{{page.name}}"
                                       type="text">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="control-label col-md-2">状态</label>

                            <div class="col-md-7">
                                <label class="radio-inline"><input name="status" type="radio"
                                                                   {{#eq page.status 1}}checked="checked" {{/eq}}
                                    value="1"><span>开启</span></label>
                                <label class="radio-inline"><input name="status" type="radio"
                                                                   {{#eq page.status 0}}checked="checked" {{/eq}}
                                    value="0"><span>关闭</span></label>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">备注</label>

                            <div class="col-sm-10">
                                <input class="form-control" name="remark" placeholder="" value="{{page.remark}}"
                                       type="text">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">详情</label>

                            <div class="col-md-10">
                                <!-- 加载编辑器的容器 -->
                                <textarea id="editor" name="detail" style="height:400px;display:none">
                                    {{{page.detail}}}
                                </textarea>
                            </div>
                        </div>
                    </div>

                    <!-- /.box-body -->

                    <div class="box-footer">
                        <div class="col-sm-2">
                            <button type="submit" class="btn btn-block btn-danger">保存</button>
                        </div>

                        <div class="col-sm-2">
                            <button type="button" class="btn btn-block btn-default" onclick="history.go(-1)">取消
                            </button>
                        </div>
                    </div>
                </form>
            </div>
            <!-- /.box -->
        </div>
        <!--/.col (right) -->
    </div>
</section>

<script type="text/javascript">
    $(document).ready(function () {

        var editorContainer = $('.wangEditor-container');
        if(!editorContainer.length){

            var editor = new wangEditor('editor');
            editor.config.menuFixed = false;
            editor.config.uploadImgUrl = '/admin/editor/add';
            editor.config.uploadImgFileName = 'file';
            editor.config.menus = $.map(wangEditor.config.menus, function(item, key) {
                if (item === 'location') {
                    return null;
                }
                return item;
            });

            editor.create();
        }
    });
</script>